#tag Module
Protected Module BoardFunctions
	#tag Method, Flags = &h21
		Private Function GetYRelativeToStartTile_deprecated(y as integer) As integer
		  return floor((winMain.canBoard.Height/medievo.TILESIZE)/2) _
		  * medievo.TILESIZE + winmain.xyScroll.y - y
		  
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h21
		Private Function GetXRelativeToStartTile_deprecated(x as integer) As integer
		  
		  
		  
		  return floor((winMain.canBoard.Height/medievo.TILESIZE)/2) _
		  * medievo.TILESIZE + winmain.xyScroll.x - x
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetXyRelativeToStartTile(pos as coordinates) As coordinates
		  dim relativePosition as Coordinates
		  dim startTilePosition as Coordinates
		  
		  startTilePosition.x = floor((winMain.canBoard.Width/medievo.TILESIZE)/2) _
		  * medievo.TILESIZE + winmain.xyScroll.x
		  startTilePosition.y = floor((winMain.canBoard.Height/medievo.TILESIZE)/2) _
		  * medievo.TILESIZE + winMain.xyScroll.y
		  
		  if pos.x < 0 then
		    relativePosition.x = startTilePosition.x + pos.x *100
		  elseif pos.x > 0 then
		    relativePosition.x = startTilePosition.x + pos.x * 100
		  else
		    relativePosition.x = startTilePosition.x
		  end if
		  
		  if pos.y < 0 then
		    relativePosition.y = startTilePosition.y - pos.y *100
		  elseif pos.y > 0 then
		    relativePosition.y = startTilePosition.y - pos.y * 100
		  else
		    relativePosition.y = startTilePosition.y
		  end if
		  
		  return relativePosition
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h21
		Private Function GetStarttileXyRelativeToCanvas_deprecated() As coordinates
		  dim startPosition as Coordinates
		  
		  startPosition.x = 0
		  startPosition.y = 0
		  
		  return GetXyRelativeToStartTile(startPosition)
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetAbsolutePositionByXy(x as integer, y as integer) As coordinates
		  dim sX as integer
		  dim sY as integer
		  dim absolutePosition as Coordinates
		  
		  sX = floor((winMain.canBoard.Width/app.TILESIZE)/2)*app.TILESIZE + winMain.xyScroll.x
		  absolutePosition.x = (floor(x/app.TILESIZE)* app.TILESIZE - sX)/app.TILESIZE
		  sY = floor((winMain.canBoard.Height/app.TILESIZE)/2)*app.TILESIZE + winMain.xyScroll.y
		  absolutePosition.y = (sY - floor(y/app.TILESIZE)*app.TILESIZE)/app.TILESIZE
		  
		  
		  return absolutePosition
		End Function
	#tag EndMethod


	#tag ViewBehavior
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InitialValue="-2147483648"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
	#tag EndViewBehavior
End Module
#tag EndModule
